<html>
<head>
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.bar.js" ></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->
    
    <link rel="stylesheet" href="../css/animations.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
    
    <meta name="description" content="A demonstration of how you can add CSS3 animations to your charts" />
    
</head>
<body>

    <h1>CSS3 animations</h1>
    
    <p>
        New CSS3 animations can be used to great effect with your canvas tags. <b>Updated:</b> This demo was updated on the 20th June
        2013 so that now instead of just one switch between charts it repeatedly switches back and forth between charts.
    </p>

    <canvas id="cvs" width="600" height="250">[No canvas support]</canvas>
    
    <br />
    
    <script>
        chart = 1;

        /**
        * Draws the blue bar chart
        */
        function drawBar1 ()
        {
            var bar = new RGraph.Bar({
                id: 'cvs',
                data: [4,5,3,8,4,9,6,5,3],
                options: {
                    colors: ['blue'],
                    labels: ['Mal', 'Barry', 'Gary', 'Neil', 'Kim', 'Pete', 'Lou', 'Fred', 'Jobe'],
                    strokestyle: 'rgba(0,0,0,0)'
                }
            }).draw();
        }




        /**
        * Draws the red bar chart
        */
        function drawBar2 ()
        {
            var bar2 = new RGraph.Bar({
                id: 'cvs',
                data: [4,8,5,4,8,6,3,5,2],
                colors: ['red'],
                labels: ['Mal', 'Barry', 'Gary', 'Neil', 'Kim', 'Pete', 'Lou', 'Fred', 'Jobe'],
                strokestyle: 'rgba(0,0,0,0)'
            }).draw();
        }




        /**
        * The swap function
        */
        function swap ()
        {
            $('#cvs').addClass('animated bounceOutLeft');
            setTimeout(function ()
            {
                RGraph.Reset(document.getElementById("cvs"));

                if (chart == 2) {
                    drawBar1();
                    chart = 1;
                } else {
                    drawBar2();
                    chart = 2;
                }

                $('#cvs').removeClass('bounceOutLeft');
                $('#cvs').addClass('bounceInLeft');
            }, 750)
        }
        
        /**
        * Start with the first bar chart
        */
        drawBar1();
        chart = 1;
    </script>
    
    <button onclick="swap()">Click me</button>

</body>
</html>